Missions page and start page layouts changed

jamesperet 11 years ago
parent
commit
d6625cb6c5

BIN
.DS_Store


BIN
app/.DS_Store


BIN
app/assets/.DS_Store


BIN
app/assets/images/header-bg.jpg


BIN
app/assets/javascripts/.DS_Store


+ 18 - 0
app/assets/stylesheets/missions.css.less

@@ -1,3 +1,21 @@
1 1
 // Place all the styles related to the missions controller here.
2 2
 // They will automatically be included in application.css.
3 3
 // You can use Less here: http://lesscss.org/
4
+
5
+.mission_thumb {
6
+	height: 178px;
7
+}
8
+
9
+.mission_thumb h3, .mission_thumb h5  {
10
+	padding-top: 0px;
11
+	padding-left: 5px;
12
+	padding-right: 5px;
13
+	margin-top: -10px;
14
+}
15
+
16
+.mission_thumb small {
17
+	padding-top: 5px;
18
+	padding-left: 5px;
19
+	padding-right: 5px;
20
+	font-weight: bold;
21
+}

+ 59 - 0
app/assets/stylesheets/start.css.less

@@ -1,3 +1,62 @@
1 1
 // Place all the styles related to the start controller here.
2 2
 // They will automatically be included in application.css.
3 3
 // You can use Less here: http://lesscss.org/
4
+
5
+header {
6
+    text-align: center;
7
+    color: #fff;
8
+    background-attachment: scroll;
9
+    background-image: image-url("header-bg.jpg");
10
+    background-position: center center;
11
+    background-repeat: none;
12
+    -webkit-background-size: cover;
13
+    -moz-background-size: cover;
14
+    background-size: cover;
15
+    -o-background-size: cover;
16
+}
17
+
18
+header .intro-text {
19
+    padding-top: 100px;
20
+    padding-bottom: 50px;
21
+}
22
+
23
+header .intro-text .intro-lead-in {
24
+    margin-bottom: 25px;
25
+    font-family: "Droid Serif","Helvetica Neue",Helvetica,Arial,sans-serif;
26
+    font-size: 22px;
27
+    font-style: italic;
28
+    line-height: 22px;
29
+}
30
+
31
+header .intro-text .intro-heading {
32
+    margin-bottom: 25px;
33
+    text-transform: uppercase;
34
+    font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
35
+    font-size: 50px;
36
+    font-weight: 700;
37
+    line-height: 50px;
38
+}
39
+
40
+@media(min-width:768px) {
41
+    header .intro-text {
42
+        padding-top: 300px;
43
+        padding-bottom: 200px;
44
+    }
45
+
46
+    header .intro-text .intro-lead-in {
47
+        margin-bottom: 25px;
48
+        font-family: "Droid Serif","Helvetica Neue",Helvetica,Arial,sans-serif;
49
+        font-size: 40px;
50
+        font-style: italic;
51
+        line-height: 40px;
52
+    }
53
+
54
+    header .intro-text .intro-heading {
55
+        margin-bottom: 50px;
56
+        text-transform: uppercase;
57
+        font-family: Montserrat,"Helvetica Neue",Helvetica,Arial,sans-serif;
58
+        font-size: 75px;
59
+        font-weight: 700;
60
+        line-height: 75px;
61
+    }
62
+}

+ 1 - 1
app/controllers/application_controller.rb

@@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
7 7
 
8 8
   def configure_permitted_parameters
9 9
     devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :location, :current_password) }
10
-    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :location) }
10
+    devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :location) }
11 11
   end
12 12
   
13 13
 end

+ 20 - 22
app/controllers/missions_controller.rb

@@ -31,10 +31,9 @@ class MissionsController < ApplicationController
31 31
   # GET /missions/new
32 32
   def new
33 33
     @mission = Mission.new
34
-    @mission.mission_agents.build
35
-    @mission.mission_agents.each do |agent|
36
-      agent.mission_agent_steps.build
37
-    end
34
+    @mission.save
35
+    a = @mission.mission_agents.new
36
+    a.save
38 37
   end
39 38
 
40 39
   # GET /missions/1/edit
@@ -66,27 +65,26 @@ class MissionsController < ApplicationController
66 65
         @mission.assign_attributes(params[:mission_agents_attributes])
67 66
         @mission.assign_attributes(params[:mission_agent_steps_attributes])
68 67
         params[:mission][:mission_agents_attributes].values.each do |a|
69
-          a[:mission_agent_steps_attributes].values.each do |s|
70
-            @step = MissionAgentStep.find(s[:id])
71
-            if s[:_destroy] == 1.to_s
72
-              @step.destroy
73
-            else
74
-              @step.description = s[:description]
75
-              @step.save
76
-            end
77
-            # Update Step Order
78
-            @steps = MissionAgentStep.order(:step => :asc).find_all_by_mission_agent_id(@step.mission_agent)
79
-            @step_number = 1
80
-            @steps.each do |step|
81
-              step.step = @step_number
82
-              step.save
83
-              @step_number = @step_number + 1
68
+          if a[:mission_agent_steps_attributes] != nil
69
+            a[:mission_agent_steps_attributes].values.each do |s|
70
+              @step = MissionAgentStep.find(s[:id])
71
+              if s[:_destroy] == 1.to_s
72
+                @step.destroy
73
+              else
74
+                @step.description = s[:description]
75
+                @step.save
76
+              end
77
+              # Update Step Order
78
+              @steps = MissionAgentStep.order(:step => :asc).find_all_by_mission_agent_id(@step.mission_agent)
79
+              @step_number = 1
80
+              @steps.each do |step|
81
+                step.step = @step_number
82
+                step.save
83
+                @step_number = @step_number + 1
84
+              end
84 85
             end
85 86
           end
86 87
         end
87
-        
88
-        
89
-
90 88
         format.html { redirect_to mission_control_path(@mission), notice: 'Mission was successfully updated.' }
91 89
         format.json { head :no_content }
92 90
       else

+ 1 - 1
app/controllers/start_controller.rb

@@ -1,6 +1,6 @@
1 1
 class StartController < ApplicationController
2 2
   
3
-  layout 'front_end'
3
+  layout 'start'
4 4
   
5 5
   def index
6 6
   end

+ 7 - 1
app/views/agent/agent_profile.html.erb

@@ -1 +1,7 @@
1
-<h1><%= @user.email %></h1>
1
+<h1>
2
+	<% if @user.username != nil %>
3
+		<%= @user.username %>
4
+	<% else %>
5
+		<%= @user.email %>
6
+	<% end %>
7
+</h1>

+ 1 - 1
app/views/layouts/partials/_logo.html.erb

@@ -1 +1 @@
1
-<a class="brand" href="/">Avalanche Game</a>
1
+<a class="brand" href="/">AVALANCHE</a>

+ 1 - 1
app/views/layouts/partials/_nav_links.html.erb

@@ -2,7 +2,7 @@
2 2
    <% if user_signed_in? %>
3 3
    	<li><%= link_to "Missions", missions_path  %></li>
4 4
    <% else %>
5
-   	<li><%= link_to "About", start_about_path  %></li>
5
+   	<li><% link_to "About", start_about_path  %></li>
6 6
    	
7 7
    <% end %>
8 8
 </ul>

+ 64 - 0
app/views/layouts/start.html.erb

@@ -0,0 +1,64 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
6
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+    <title><%= content_for?(:title) ? yield(:title) : "AvalancheGame" %></title>
8
+    <%= csrf_meta_tags %>
9
+
10
+    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
11
+    <!--[if lt IE 9]>
12
+      <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
13
+    <![endif]-->
14
+
15
+    <%= stylesheet_link_tag "application", :media => "all" %>
16
+
17
+    <!-- For third-generation iPad with high-resolution Retina display: -->
18
+    <!-- Size should be 144 x 144 pixels -->
19
+    <%= favicon_link_tag 'apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>
20
+
21
+    <!-- For iPhone with high-resolution Retina display: -->
22
+    <!-- Size should be 114 x 114 pixels -->
23
+    <%= favicon_link_tag 'apple-touch-icon-114x114-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '114x114' %>
24
+
25
+    <!-- For first- and second-generation iPad: -->
26
+    <!-- Size should be 72 x 72 pixels -->
27
+    <%= favicon_link_tag 'apple-touch-icon-72x72-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '72x72' %>
28
+
29
+    <!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices: -->
30
+    <!-- Size should be 57 x 57 pixels -->
31
+    <%= favicon_link_tag 'apple-touch-icon-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png' %>
32
+
33
+    <!-- For all other devices -->
34
+    <!-- Size should be 32 x 32 pixels -->
35
+    <%= favicon_link_tag 'favicon.ico', :rel => 'shortcut icon' %>
36
+
37
+    <%= javascript_include_tag "application" %>
38
+  </head>
39
+  <body>
40
+
41
+    <div class="navbar navbar-fixed-top">
42
+      <div class="navbar-inner">
43
+        <div class="container">
44
+          <a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
45
+            <span class="icon-bar"></span>
46
+            <span class="icon-bar"></span>
47
+            <span class="icon-bar"></span>
48
+          </a>
49
+          <%= render 'layouts/partials/logo' %>
50
+          <div class="container nav-collapse">
51
+            <%= render 'layouts/partials/nav_links' %>
52
+          </div><!--/.nav-collapse -->
53
+        </div>
54
+      </div>
55
+    </div>
56
+    <%= yield %>
57
+
58
+    <%= render 'layouts/partials/footer' %>
59
+
60
+
61
+    </div> <!-- /container -->
62
+
63
+  </body>
64
+</html>

+ 1 - 0
app/views/missions/_form.html.erb

@@ -1,6 +1,7 @@
1 1
 <%= simple_form_for(@mission) do |f| %>
2 2
   <%= f.error_notification %>
3 3
   <div class="form-inputs">
4
+    <%= f.hidden_field :id%>
4 5
     <%= f.input :title %>
5 6
     <%= f.input :description %>
6 7
     <%= f.input :status %>

+ 1 - 0
app/views/missions/_mission_agent_steps_count.html.erb

@@ -0,0 +1 @@
1
+<%= invite.mission_agent.mission_agent_steps.where(:completed => true).length %>/<%= invite.mission_agent.mission_agent_steps.length %>

+ 13 - 0
app/views/missions/_mission_alert_badge.html.erb

@@ -0,0 +1,13 @@
1
+<% @alert = 0 %>
2
+
3
+<% mission.mission_agents.each do |agent|%>
4
+	<% agent.mission_agent_steps.each do |step| %>
5
+		<% if step.status == "Waiting Validation" %>
6
+			<% @alert = @alert + 1 %>
7
+		<% end%>
8
+	<% end %>
9
+<% end %>
10
+
11
+<% if @alert > 0 %>
12
+	<span class="badge badge-warning"><%= @alert %></span>
13
+<% end %>

+ 19 - 6
app/views/missions/_mission_status.html.erb

@@ -1,6 +1,19 @@
1
-<span class="label <%= @status_label %> pull-right" style="margin-top: 2px; padding-left: 20px; padding-right: 20px">
2
-		  <h4 style="text-align: center">
3
-			  <small style="color: white">status:</small><br>
4
-			  <%= @mission.status %>
5
-		  </h4>
6
-	  </span>
1
+<% if mission.status == 'Initializing' %>
2
+	<% @status_label = 'label'%>
3
+<% end%>
4
+<% if mission.status == 'Launched' %>
5
+	<% @status_label = 'label-success'%>
6
+<% end%>
7
+
8
+<% if big == true %>
9
+	<span class="label <%= @status_label %> pull-right" style="margin-top: 2px; padding-left: 20px; padding-right: 20px">
10
+	  <h4 style="text-align: center">
11
+		  <small style="color: white">status:</small><br>
12
+		  <%= mission.status %>
13
+	  </h4>
14
+	</span>
15
+<% else %>
16
+	<span class="label <%= @status_label %> pull-right" style="margin-top: 10px;">
17
+		 <%= mission.status %>
18
+	</span>
19
+<% end%>

+ 67 - 51
app/views/missions/index.html.erb

@@ -1,54 +1,70 @@
1
-<% if @mission_invites.length > 0 %>
2
-	<div class="page-header">
3
-	  <h1>Choose your Missions </h1>
4
-	</div>
5
-	<ul class="thumbnails">
6
-	<% @mission_invites.each do |invite| %>
7
-		<li class="span4">
8
-		    <div class="thumbnail" style= "padding: 5px;">
9
-		      <h3 style= "padding: 5px;"><%= invite.mission_agent.mission.title %></h3>
10
-		      <p style= "padding: 5px; height: 50px;"><%= invite.mission_agent.mission.description %></p>
11
-			 <div style="width: 48%; float: left;">
12
-				 <%= link_to 'accept', mission_agent_accept_path(invite.id), :class => "btn btn-large btn-block btn-success" %>
13
-			 </div>
14
-			 <div style="width: 48%; float: right;">
15
-			 	<%= link_to 'Denie', mission_agent_denie_path(invite.id), :class => "btn btn-large btn-block btn-danger" %>
16
-			 </div>
17
-			 <div class="clearfix"></div>
18
-		    </div>
19
-		</li>
20
-	<% end %>
21
-	</ul>
22
-<% end %>
23
-
24
-<% if @missions.length > 0%>
25
-	<div class="page-header">
26
-	  <h1>Assigned Missions</h1>
27
-	</div>
28
-	<ul class="thumbnails">
29
-	<% @missions.each do |invite| %>
30
-		<li class="span4">
31
-		    <div class="thumbnail" style= "padding: 5px;">
32
-			      <h3 style= "padding: 5px;"><%= link_to invite.mission_agent.mission.title, mission_path(invite.mission_agent.mission) %></h3>
1
+<div class="page-header">
2
+  <h1>Missions Dashboard</h1>
3
+</div>
4
+<ul class="thumbnails">
5
+	<% if @mission_invites.length > 0 %>
6
+		<% @mission_invites.each do |invite| %>
7
+			<li class="span4">
8
+			    <div class="thumbnail mission_thumb" >
9
+				 <small>Mission Invite</small>
10
+			      <h3><%= invite.mission_agent.mission.title %></h3>
33 11
 			      <p style= "padding: 5px; height: 50px;"><%= invite.mission_agent.mission.description %></p>
34
-		    </div>
35
-		</li>
12
+				 <div style="width: 48%; float: left;">
13
+					 <%= link_to 'accept', mission_agent_accept_path(invite.id), :class => "btn btn-large btn-block btn-success" %>
14
+				 </div>
15
+				 <div style="width: 48%; float: right;">
16
+				 	<%= link_to 'Denie', mission_agent_denie_path(invite.id), :class => "btn btn-large btn-block btn-danger" %>
17
+				 </div>
18
+				 <div class="clearfix"></div>
19
+			    </div>
20
+			</li>
21
+		<% end %>
36 22
 	<% end %>
37
-	</ul>
38
-<% end %>	
39 23
 
40
-<% if @mission_control.length > 0 %>
41
-	<div class="page-header">
42
-	  <h1>Missions Control</h1>
43
-	</div>
44
-	<ul class="thumbnails">
45
-	<% @mission_control.each do |mission| %>
46
-		<li class="span4">
47
-		    <div class="thumbnail" style= "padding: 5px;">
48
-			      <h3 style= "padding: 5px;"><%= link_to mission.title, mission_control_path(mission) %></h3>
49
-			      <p style= "padding: 5px; height: 50px;"><%= mission.description %></p>
50
-		    </div>
51
-		</li>
52
-	<% end %>
53
-	</ul>
54
-<% end%>
24
+	<% if @missions.length > 0%>
25
+		<% @missions.each do |invite| %>
26
+			<% if invite.user != invite.mission_agent.mission.owner %>
27
+				<li class="span4">
28
+				    <div class="thumbnail mission_thumb" >
29
+					      <small>Mission Details</small>
30
+					      <h3><%= invite.mission_agent.mission.title %> <%= render 'mission_status', :mission => invite.mission_agent.mission, :big => false %></h3>
31
+						 <h5 >Steps Completed: <%= render 'mission_agent_steps_count', :invite => invite %></h5>
32
+					      <p style= "padding: 5px; height: 50px;"><%= invite.mission_agent.mission.description %></p>
33
+						 <%= link_to 'View Mission Details', mission_path(invite.mission_agent.mission), :class => "btn btn-small btn-block btn-default" %>
34
+				    </div>
35
+				</li>
36
+			<% end %>
37
+		<% end %>
38
+	<% end %>	
39
+
40
+	<% if @mission_control.length > 0 %>
41
+			<% @mission_control.each do |mission| %>
42
+				<li class="span4">
43
+				    <div class="thumbnail mission_thumb">
44
+					      <small>Mission Control</small>
45
+					      <h3><%= mission.title %> <%= render 'mission_alert_badge', :mission => mission %> <%= render 'mission_status', :mission => mission, :big => false %></h3>
46
+						 <h5 >Agents: <%= mission.mission_agents.length %></h5>
47
+					      <p style= "padding: 5px; height: 50px;"><%= mission.description %></p>
48
+						 <% @owner_agent = false %>
49
+						 <% mission.mission_agents.each do |agent| %>
50
+						 	<% if agent.user == mission.owner %>
51
+								<% if agent.mission_agent_invites.where(:user => agent.user).last.status == "Accepted" || agent.mission_agent_invites.where(:user => agent.user).last.status == "Completed"%>
52
+									<% @owner_agent = true %>
53
+					    				 <div style="width: 48%; float: left;">
54
+					    					 <%= link_to 'View Mission Details', mission_path(mission), :class => "btn btn-small btn-block btn-default" %>
55
+					    				 </div>
56
+					    				 <div style="width: 48%; float: right;">
57
+					    				 	<%= link_to 'Open Mission Control', mission_control_path(mission), :class => "btn btn-small btn-block btn-default" %>
58
+					    				 </div>
59
+					    				 <div class="clearfix"></div>
60
+								<% end%>
61
+							 <% end %>
62
+						<% end %>
63
+						<% if @owner_agent != true %>
64
+							<%= link_to 'Open Mission Control', mission_control_path(mission), :class => "btn btn-small btn-block btn-default" %>
65
+						<% end %>
66
+				    </div>
67
+				</li>
68
+			<% end %>
69
+	<% end%>
70
+</ul>

+ 2 - 7
app/views/missions/mission_control.html.erb

@@ -3,13 +3,8 @@
3 3
 	  Mission Control
4 4
 	   <%= link_to 'Edit', edit_mission_path(@mission), :class => 'btn btn-mini btn-default' %>
5 5
 	   <%= link_to 'Launch', mission_launch_path, :class => 'btn btn-mini btn-danger' %>
6
-	  <% if @mission.status == 'Initializing' %>
7
-	  	<% @status_label = 'label'%>
8
-	  <% end%>
9
-	  <% if @mission.status == 'Launched' %>
10
-	  	<% @status_label = 'label-success'%>
11
-	  <% end%>
12
-  	  <%= render 'mission_status' %>
6
+	  
7
+  	   <%= render 'mission_status', :mission => @mission, :big => true %>
13 8
 
14 9
   </h1>
15 10
   <small>Director: <%= link_to @mission.owner.username, agent_profile_path(@mission.owner.id) %></small>

+ 1 - 7
app/views/missions/show.html.erb

@@ -1,13 +1,7 @@
1 1
 <div class="page-header">
2 2
   <h1>
3 3
 	  <%= @mission.title %> <small>(Mission Details)</small>
4
-	  <% if @mission.status == 'Initializing' %>
5
-	  	<% @status_label = 'label'%>
6
-	  <% end%>
7
-	  <% if @mission.status == 'Launched' %>
8
-	  	<% @status_label = 'label-success'%>
9
-	  <% end%>
10
-  	  <%= render 'mission_status' %>
4
+  	  <%= render 'mission_status', :mission => @mission, :big => true %>
11 5
   </h1>
12 6
   <small>Director: <%= link_to @mission.owner.username, agent_profile_path(@mission.owner.id) %></small>
13 7
 </div>

+ 15 - 2
app/views/start/index.html.erb

@@ -1,2 +1,15 @@
1
-<h1>Start#index</h1>
2
-<p>Find me in app/views/start/index.html.erb</p>
1
+<header>
2
+   <div class="container">
3
+       <div class="intro-text">
4
+           <div class="intro-lead-in">
5
+			 So you want to become an agent?
6
+		</div>
7
+           <div class="intro-heading">
8
+			 Welcome to Avalanche
9
+		 </div>
10
+		 <% if !user_signed_in? %>
11
+		 	<%= link_to "Sign Up", new_user_registration_path, :class => 'btn btn-large btn-success'  %>
12
+		 <% end %>
13
+       </div>
14
+   </div>
15
+</header>

BIN
public/.DS_Store